package Coding.Exception;
// 自定义异常
//测试异常
public class ILLegalAgeException extends  Exception{

    public ILLegalAgeException() {
    }

    public ILLegalAgeException(String message) {
        super(message);
    }

    public ILLegalAgeException(String message, Throwable cause) {
        super(message, cause);
    }

    public ILLegalAgeException(Throwable cause) {
        super(cause);
    }

    public ILLegalAgeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }
}

class PersonIllegalException{



        int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws  ILLegalAgeException{
        if (age<0 || age>100){
            throw new ILLegalAgeException("不合法");
        }
        this.age = age;
    }
}

class TestIll{

    public static void main(String[] args) {

        PersonIllegalException personIllegalException = new PersonIllegalException();

        try {
            personIllegalException.setAge(10000);
        } catch (ILLegalAgeException e) {
            e.printStackTrace();
        }
    }
}